/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2022年3月13日
 */
package com.massyframework.beanskin.service;

import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;

import com.massyframework.beanskin.service.DependencyServiceDescriptor;

/**
 * 多个依赖服务定义所构成的组
 * @author huangkh
 *
 */
public interface DependencyServiceDescriptors {
	
	/**
	 * 判断是否包含{@link DependencyServiceDescriptor}定义
	 * @param descriptor {@link DependencyServiceDescriptor}
	 * @return {@link boolean},返回{@code true}表示包含，否则返回{@code false}
	 */
	boolean containsDependencyService(DependencyServiceDescriptor<?> descriptor);

	/**
	 * 满足{@code filter}条件的首个依赖服务定义
	 * @param filter {@link Predicate},过滤条件
	 * @return {@link DependencyServiceDescriptor},可能返回null.
	 */
	DependencyServiceDescriptor<?> findByFilter(Predicate<DependencyServiceDescriptor<?>> filter);
	
	/**
	 * 所有成员
	 * @return {@link List}
	 */
	List<DependencyServiceDescriptor<?>> getItems();
	
	/**
	 * 满足{@code filter}条件的所有依赖服务定义
	 * @param filter
	 * @return
	 */
	List<DependencyServiceDescriptor<?>> getItemsByFilter(Predicate<DependencyServiceDescriptor<?>> filter);
	
	/**
	 * 经过{@code action}处理后的依赖服务定义
	 * @param action {@link Function},流处理函数
	 * @return {@link List}
	 */
	List<DependencyServiceDescriptor<?>> getItemsByAction(Function<Stream<DependencyServiceDescriptor<?>>, Stream<DependencyServiceDescriptor<?>>> action);
	
	/**
	 * 成员数量
	 * @return {@link int}
	 */
	int size();
}
